package com.guli.auth.controller;

import com.guli.auth.service.RegisterService;
import com.guli.auth.vo.UserVo;
import com.guli.common.utils.R;
import com.guli.common.valid.AddGroup;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.annotation.Resource;

/*
 * @Author 罗
 * @date 2020/10/18 - 3:52 下午
 */
@RestController
@RequestMapping("/register")
public class RegisterController {

    @Resource
    RegisterService registerService;

    @PostMapping("/registerUser")
    public R registerUser(@RequestBody @Validated(AddGroup.class) UserVo userVo){

        return registerService.register(userVo);

    }

    @PostMapping("/hello")
    public String hello(RedirectAttributes redirectAttributes){

        redirectAttributes.addFlashAttribute("name","罗俊华");

        return "redirect:/index.html";
    }
}
